package mobile.game.core.config;

import mobile.game.core.support.SysException;
import mobile.game.core.support.Utils;

/**
 * @author gaopan
 *
 * 每个渠道的最大注册人数
 */
public class ChannelMax {
	/** 总人数配置 */
	public static final String SERVICE_TOTAL = "total";
	/** 默认渠道id */
	public static final String SERVICE_DEF = "def";
	
	/** 渠道名 */
	private String serviceName;
	/** 渠道ID */
	private String serviceId;
	/** 允许该渠道的最大注册人数(0:无限制   <0：禁止该渠道进入) */
	private int max;
	
	/** 该渠道的当前注册人数 */
	private int now;
	
	public ChannelMax(String config) {
		String[] strs = config.split(",");
		if(strs.length != 3) {
			throw new SysException("Config invalid, config={}", config);
		}
		
		this.serviceName = strs[0];
		this.serviceId = strs[1];
		this.max = Utils.intValue(strs[2]);
	}

	public boolean isFull() {
		return getNow() >= getMax();
	}

	public String getServiceName() {
		return serviceName;
	}

	public void setServiceName(String serviceName) {
		this.serviceName = serviceName;
	}

	public String getServiceId() {
		return serviceId;
	}

	public void setServiceId(String serviceId) {
		this.serviceId = serviceId;
	}

	public int getMax() {
		return max;
	}

	public void setMax(int max) {
		this.max = max;
	}

	public int getNow() {
		return now;
	}

	public void setNow(int now) {
		this.now = now;
	}
}
